package gist.enun;

/**
 * switch使用枚举
 * Created by gss on 2017/5/4.
 */
enum Signal{
    green,yellow,red
}
public class TrafficLight {
    Signal color=Signal.red;
    public  void change(){
        switch (color){
            case red:
                color=Signal.green;
                break;
            case green:
                color=Signal.yellow;
                break;
            case yellow:
                color=Signal.red;
                break;
        }
        System.out.println(color);
    }

    public static void main(String[] args) {
        TrafficLight trafficLight=new TrafficLight();
        trafficLight.change();
    }
}
